package net.ufrog.common.converters;

import net.ufrog.common.utils.Strings;

/**
 * @author ultrafrog, ufrog.net@gmail.com
 * @version 0.1, 2017-07-04
 * @since 0.1
 */
public class StringConverter extends Converter<String> {

    @Override
    public String convert(Object obj, Object defaultValue) {
        if (obj != null) {
            return String.valueOf(obj);
        } else if (defaultValue != null) {
            return Strings.empty(String.valueOf(defaultValue), null);
        } else {
            return null;
        }
    }

    @Override
    public Class<String> getType() {
        return String.class;
    }
}
